using System;
using System.CodeDom;
using System.Windows.Threading;
using WPFCommon.Interface;

namespace ALC.Core.ViewModels.Chart
{
    public class DataProviderMock : IDataProvider
    {
        
        private Random _random = new Random();
        
        public event Action<double> NextDataReady;

        protected virtual void OnNextDataReady(double data)
        {
            NextDataReady?.Invoke(data);
        }

        public DataProviderMock()
        {
            var timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(200);
            timer.Tick += SentNextData;
            timer.Start();
        }

        private void SentNextData(object sender, EventArgs e)
        {
            OnNextDataReady(_random.Next(50, 150));
        }
    }
}